package com.second.app.thread.threadlocal.tools;


import org.apache.commons.lang3.StringUtils;

/**
 * @author gyz
 * @date 2021/1/29 15:15
 */
public class SonTheadB extends Thread {

    @Override
    public void run() {
        try {
            if (StringUtils.isEmpty(Tool.t1.get())) {
                int value = (int) (Math.random() * 1000);
                Tool.t1.set(value + "");
                System.out.println(Thread.currentThread().getName() + "存入值：" + value);
            }
            Thread.sleep(1000);
            System.out.println(Thread.currentThread().getName() + "获取值：" + Tool.t1.get());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
